﻿#pragma once

#include "pch.h"

struct TcpSocket
{
	struct Desc
	{
		const char* host;
		unsigned int port;

		unsigned int af = AF_INET;
		unsigned int type = SOCK_STREAM;
		unsigned int protocol = IPPROTO_TCP;

		unsigned int sinFamily = AF_INET;
	};

    uint64_t sock;
	bool Create(TcpSocket::Desc desc);
	void Close();

	template<typename T>
	int Recv(T& t)
	{
        return recv(sock, (char*)&t, sizeof(T), 0);
	}
	template<typename T>
	int Send(const T& t)
	{
        return send(sock, (const char*)&t, sizeof(T), 0);
	}

};
